package net.zjitc.search;

public class a  {
    public static void main(String[] args) {
        int arr[] = {1,2,3,4,5,6,7,8,9};
        int index = findData(arr,3);
        System.out.println(index);
    }
    public static int findData(int[]arr, int k) {
        int left,right,mid;
        left = 0;
        right = arr.length-1;
        while (left<=right){
            mid = (left+right)/2;
            if (k > arr[mid]){
                left = mid+1;
            }else if(k<arr[mid]){
                right = mid-1;
            }else {
                return mid;
            }
        }
        return -1;
    }

    }



